package tongwentongshu.com.app.adapter;


import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.util.Log;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import tongwentongshu.com.app.R;
import tongwentongshu.com.app.bean.BookListBean;
import tongwentongshu.com.app.bean.ReadingStatus;
import tongwentongshu.com.app.utils.GlideUtil;

/**
 * 文 件 名: MainBooksAdapter
 * 创 建 人: Allen
 * 创建日期: 16/12/24 19:55
 * 邮   箱: AllenCoder@126.com
 * 修改时间：
 * 修改备注：
 */
public class MainBooksAdapter extends BaseQuickAdapter<BookListBean.DataBean, BaseViewHolder> {
    private Context mContext;

    public MainBooksAdapter(Context mContext, List<BookListBean.DataBean> list) {
        super(R.layout.view_reading, list);
        this.mContext = mContext;

    }

    @Override
    protected void convert(BaseViewHolder helper, BookListBean.DataBean item) {
        helper.setText(R.id.tv_book_name, "【" + item.getBook_typename() + "】" + item.getBook_name());
        helper.setText(R.id.tv_book_info, item.getBook_introduce());
        TextView status = (TextView) helper.getView(R.id.tv_book_status);
        Button btn = (Button) helper.getView(R.id.btn_book_see);
        status.setText(item.getBookstatus());
        switch (item.getBookstatus()) {
            case "空闲":
                btn.setText("求带走~");
//                status.setTextColor(mContext.getResources().getColor(R.color.title_green));
                status.setTextColor(Color.rgb(58, 190, 85));
                helper.setImageResource(R.id.iv_book_status, R.drawable.status_reading);
                break;
            case "在读":
                btn.setText("好想看看");
                status.setTextColor(Color.rgb(58, 190, 85));
                helper.setImageResource(R.id.iv_book_status, R.drawable.status_to_reading);
                break;
            case "被预约":
                btn.setText("好想看看");
                status.setTextColor(Color.rgb(58, 190, 85));
                helper.setImageResource(R.id.iv_book_status, R.drawable.status_time);
                break;
            default:
                break;
        }
        Log.e("bookid", "bookid=" + item.getBook_id());
        GlideUtil.setImage1(mContext, item.getImage(), R.drawable.default_graph, R.drawable.default_graph, (ImageView) helper.getView(R.id.iv_book_image));
    }


}
